﻿@using View = System.Web.UI.WebControls.View
@{
    ViewBag.Title = "DANH SÁCH CHAI CHỊU ÁP LỰC";
    var url = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/');
}
<script>
    app.controller('ReportProductListController', function ($scope, $compile, $http, $filter, service) {
        $scope.loadReport = function () {
            window.location = '@Url.Action("ProductList", "Report", new { id = String.Empty })/' + $scope.filter.LotID;
        };

        $scope.loadLot = function () {
            var url = '@url' + '@Url.Action("LotApi", "Api")';
            $http.get(url)
                .success(function (data) {
                    $scope.lots.length = 0;
                    for (var i = 0; i < data.length; i++) {
                        if (data[i].LotID == $scope.filter.LotID)
                            $scope.filter.LotCode = data[i].LotCode;

                        $scope.lots.push({ "LotID": data[i].LotID, "LotCode": data[i].LotCode, "Date": data[i].Date });
                    }
                })
                .error(function (data) {
                    service.showModal($scope, $compile, 'error', data);
                });
        };

        $scope.getValue = function (optID, lotID, lotCode) {

            $scope.filter.LotID = lotID;
            $scope.filter.LotCode = lotCode;

            $('#' + optID).toggle();
        };

        $scope.filter = { LotID: @ViewBag.LotID, LotCode: '' };
        $scope.lots = [{}];
        $scope.loadLot();
    });
</script>
<div ng-controller="ReportProductListController">
    <div id="content" class="content row">
        <div class="col-md-5" style="padding-right: 15px;">
            <div class="panel-body">
                <div class="row" style="margin-right: 0px">
                    <form class="form-inline">
                        <div class="form-group">
                            <strong class="hfs">Lô:</strong>
                        </div>
                        <div class="form-group">
                            <div class="custom-select">
                                <div class="div-select" style="width: 150px">
                                    {{filter.LotCode}}
                                </div>
                                <div id="lot-Options" class="options" style="width: 400px; z-index: 9999999; display: none; margin-top: 15px">
                                    <table class="tbl" style="width: 100%; cursor: pointer;">
                                        <tbody>
                                            <tr>
                                                <th style="text-align: left;">Mã số lô</th>
                                                <th style="text-align: left;">Ngày nhập lô</th>
                                            </tr>
                                            <tr class="option" ng-repeat="item in lots" ng-click="getValue('lot-Options', item.LotID, item.LotCode)">
                                                <td style="text-align: left;">{{item.LotCode}}</td>
                                                <td style="text-align: left;">{{item.Date | date:'dd/MM/yyyy'}}</td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <button class="btn btn-primary btn-sm" type="button" ng-click="loadReport()" style="width: 100px">
                            <i class="fa fa-search fa-fw"></i> Xem
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@if (ViewBag.LotID > 0)
{
    <table>
        <tr>
            <td>
                @Html.Partial("ExportViewerPartial")
            </td>
        </tr>
        <tr>
            <td id="report">
                @Html.Partial("DocumentViewerPartial")
            </td>
        </tr>
    </table>
}